<div class="box">
	<div class="box-body">
		<div class="row marginZero">
				<epoch:table id="templateTable"
						queryUrl="${basePath}/sys/generator/findListDbAjax" rowId="tableName" showRefresh="true"  newBtn="true"
						newBtnText="代码生成" onAddClick="codeGenerator">
						<epoch:moreBtn position="2">
		                    <button type="button" class="btn btn-primary btn-sm" onclick="generateCode();">
		                        <span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span>自定义生成器
		                    </button>
						 </epoch:moreBtn>
						<epoch:tr check="checkbox" titleTip="全选"></epoch:tr>
						<epoch:tr name="表名" formName="tableName">
						</epoch:tr>
						<epoch:tr name="Engine" formName="engine" width="10%" filterType="1212"></epoch:tr>
						<epoch:tr name="表备注" formName="tableComment" width="30%" filterType="1212"></epoch:tr>
						<epoch:tr name="创建时间" formName="createTime"  width="20%" filterType="1212"></epoch:tr>
				</epoch:table>
		</div>
	</div>
</div>
<epoch:winOpen id="code" title="代码生成器自定义" backdrop="false" width="600px" btnSave="确定">
      <form class="form-horizontal">
          <div class="form-group">
	          	<label for="firstname" class="col-sm-3 control-label">表前缀或表名称</label>
				<div class="col-sm-8">
				<input type="text" class="form-control input-sm" name="tableNameFirst" id="tableNameFirst" autocomplete="off">
				</div>
          </div>
          <div class="form-group">
	     	<label for="firstname" class="col-sm-8 control-label">(一键自动根据前缀或者表名自动生成代码)</label>
	     </div>
      </form>
</epoch:winOpen>
<script type="text/javascript">
function codeGenerator(){
	var obj = {};
	var rows = $("#templateTable").bootstrapTable("getAllSelections");
	var ids = [];
    for (var id in rows) {
        ids.push(rows[id].tablename);
    }
    obj.ids = ids;
    if(rows.length == 0){
    	MessageBox.error("请至少选择一行记录！");
        return;
    }else{
	    location.href = "${basePath}/sys/generator/code?ids=" + obj.ids.join();
    }
}

function generateCode(){
	$("#code").modal('show');
}
$("#code_save").on("click", function() {
	if($("#tableNameFirst").val() == ""){
		MessageBox.error("请输入前缀或者表名称！");
        return;
	}
	location.href = "${basePath}/sys/generator/codeStart?name=" + $("#tableNameFirst").val() ;
	$("#code").modal('hide');
});
</script>